clear all
set more off

cd "/Users/yasenov/Dropbox (IPL)/mexican_repatriates2/"
use "~/aggregate_nber.dta", replace

keep if inlist(statefip, 4, 5, 6, 8, 22, 32, 35, 40, 41, 49, 48)
keep county dmex mex_share10 pctdem
rename county ID

merge 1:1 ID using "~/shapefiles/county1910_shapefile/us1910_dta.dta", nogen keep(3)

replace pctdem = pctdem / 100
format dmex %3.2f
format mex_share10 %3.2f
format pctdem %3.2f

* DMEX
spmap dmex using "~/shapefiles/county1910_shapefile/us1910_coor.dta", ///
	id(_ID) ///
	fcolor(Greys) ///
	clbreaks(-.11 0 .01 .03 .32) ///
	legend(size(medium)) ///
	clmethod(custom) ///	
	polygon( ///
		data("~/shapefiles/state_shapefile/st99_d90_coor.dta") ///
		select(keep if inlist(_ID,94,124,125,126,136,146,147,148,152,153,160,161,162,163,164,165,166,167,174,177)) ///
		ocolor(black) ///
		osize(thin) ///
		)

graph export "~/map_panelA_dmex.png", replace
graph export "~/map_panelA_dmex.pdf", replace

* MEX SHARE 1910
spmap mex_share10 using "~/shapefiles/county1910_shapefile/us1910_coor.dta", ///
	id(_ID) ///
	fcolor(Greys) ///
	clbreaks(0 .01 .03 .1 .2 1) ///
	legend(size(medium)) ///
	clmethod(custom) ///	
	polygon( ///
		data("~/shapefiles/state_shapefile/st99_d90_coor.dta") ///
		select(keep if inlist(_ID,94,124,125,126,136,146,147,148,152,153,160,161,162,163,164,165,166,167,174,177)) ///
		ocolor(black) ///
		osize(thin) ///
		)
		
graph export "~/map_panelC_mexshare10.png", replace
graph export "~/map_panelC_mexshare10.pdf", replace
		
* DEMOCRATIC SHARE
spmap pctdem using "~/shapefiles/county1910_shapefile/us1910_coor.dta", ///
	id(_ID) ///
	fcolor(Greys) ///
	clbreaks(0 .4 .5 .7 1) ///
	legend(size(medium)) ///
	clmethod(custom) ///	
	polygon( ///
		data("~/shapefiles/state_shapefile/st99_d90_coor.dta") ///
		select(keep if inlist(_ID,94,124,125,126,136,146,147,148,152,153,160,161,162,163,164,165,166,167,174,177)) ///
		ocolor(black) ///
		osize(thin) ///
		)	
		
graph export "~/map_panelD_demshare.png", replace
graph export "~/map_panelD_demshare.pdf", replace		
